home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_all.zip
/
TI204.ASC
< prev
next >
Wrap
Text File
|
1992-08-12
|
2KB
|
133 lines
PRODUCT : TURBO PASCAL NUMBER : 204
VERSION : 2.0xx
OS : PC-DOS, MS-DOS
DATE : April 1, 1986 PAGE : 1/2
TITLE : RANDOM NUMBER SEED LOCATIONS
Turbo Pascal maintains a four byte random number seed. There is
a Randomize procedure to give that seed a random value which the
function, Random, then uses to generate random values within a
specified range.
Random : r := seed;
The function Random(value) calls the following routine:
function Random(N_Max): real;
var c1, c2, r : real;
begin
c1 := exp(32 * ln(2));
c2 := exp(16 * ln(2));
r := (r * 129 * $361962E9) mod c1;
Random := r div c2 mod N_Max;
end;
The following table gives the random number seed address for most
Turbo Pascal implementations:
Random Number Seed Locations
IBM TURBO.COM 0129
IBM TURBO-87.COM 0116
Generic TURBO.COM 0129
Generic TURBO-87.COM 0116
The seed may be declared as:
Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$0129;
or:
Var RandomSeed: Array [0..1] Of Integer Absolute DSeg:$0129;
By replacing the value in the address, you can seed the random number
generator in any way you like: read it from a file; read a number
from the user; ask for the user to hit a key, and count until he
does; get the system time; or, assign a constant va
PRODUCT : TURBO PASCAL NUMBER : 204
VERSION : 2.0xx
OS : PC-DOS, MS-DOS
DATE : April 1, 1986 PAGE : 2/2
TITLE : RANDOM NUMBER SEED LOCATIONS
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.